<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="js/PlanetBirthday.js"></script>
<title>Planet Birthday</title>
</head>
<body>
<form action="" method="get" id="form0" title="form0" onSubmit="javascript:getBirthday(this)">
<script type="text/javascript">
	var pb = new PlanetBirthday();
	var today = new Date();
	var form = document.getElementById('form0');
	var monthNames = [ null, "January", "February", "March", "April", "May",
	       			"June", "July", "August", "September", "October", "November",
	       			"December" ];
   	createDaysDropDown = function() {
   		var selectElement = document.createElement("SELECT");
   		selectElement.name = "day";
   		selectElement.id = "day";
   		var t;
   		for ( var i = 1; i < 32; ++i) {
   			var dateText = i;
   			if (dateText < 10)
   				dateText = "0" + dateText;
   			t = new Option(i, dateText);
   			selectElement.options.add(t);
   		}
   		selectElement.selectedIndex = today.getDate() - 1;
   		form.appendChild(selectElement);
   	}
   	createMonthsDropDown = function() {
   		var selectElement = document.createElement("SELECT");
   		selectElement.name = "month";
   		selectElement.id = "month";
   		var t;
   		for ( var i = 0; i < 12; ++i) {
   			t = new Option(monthNames[i + 1], i+1);
   			selectElement.options.add(t);
   		}
   		selectElement.selectedIndex = today.getMonth();
   		form.appendChild(selectElement);
   	}
   	createYearsDropDown = function() {
   		var selectElement = document.createElement("SELECT");
   		selectElement.name = "year";
   		selectElement.id = "year";
   		var t;
   		var thisYear = today.getFullYear();
   		for ( var i = thisYear; i > thisYear - 100; --i) {
   			t = new Option(i, i);
   			selectElement.options.add(t);
   		}
   		form.appendChild(selectElement);
   	}
	getBirthday = function (form){
	//alert(form.day.value)
		var day = form.day.value;
		var month = form.month.value;
		var year = form.year.value;
		var planet = form.planets.value;
		var birthday = pb.getBirthday(day, month,year, pb.PLANETS[planet].yearRatio)
		var str = ""
		//alert(birthday.birthdays.length)
		for(var i = 0; i<birthday.birthdays.length; ++i){
			str += pb.dateToMessage(birthday.birthdays[i], form.planets.value);
			if(i<birthday.birthdays.length-1)str +=", ";
		}
		//
		alert(str);
		//alert(pb.getBirthday(09, 04,1964, pb.PLANETS.earth.yearRatio).planetAge);
	}
	
	createDaysDropDown()
	createMonthsDropDown()
	createYearsDropDown();

</script>
<!--<script>document.write(createYearsDropDown());</script>-->

<script></script>

<!--<input name="month" type="text" value="04" size="2" maxlength="2" />
<input name="year" type="text" value="1964" size="4" maxlength="4" />-->
<select name="planets">
  <option value="mercury">Mercury</option>
  <option value="venus">Venus</option>
  <option value="earth" selected="selected">Earth</option>
  <option value="mars">Mars</option>
  <option value="jupiter">Jupiter</option>
  <option value="saturn">Saturn</option>
  <option value="uranus">Uranus</option>
  <option value="neptune">Neptune</option>
  <option value="lv426">LV-426</option>
  <option value="tatooine">Tatooine</option>
</select>
<br />
  <input name="submitBtn0" type="submit" id="submitBtn0"/>
</form>
</body>
</html>
